package com.ruoyi.farmer.service.impl;

import java.util.List;
import java.util.Random;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.farmer.bo.BusinessBo;
import com.ruoyi.farmer.domain.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.farmer.mapper.OrderdetailMapper;
import com.ruoyi.farmer.domain.Orderdetail;
import com.ruoyi.farmer.service.IOrderdetailService;

/**
 * 订单详情Service业务层处理
 *
 * @author 姚毫征
 * @date 2023-09-13
 */
@Service
public class OrderdetailServiceImpl implements IOrderdetailService
{
    @Autowired
    private OrderdetailMapper orderdetailMapper;

    private Orderdetail orderdetail=new Orderdetail();

    /**
     * 查询订单详情
     *
     * @param id 订单详情主键
     * @return 订单详情
     */
    @Override
    public Orderdetail selectOrderdetailById(Long id)
    {
        return orderdetailMapper.selectOrderdetailById(id);
    }

    /**
     * 查询订单详情列表
     *
     * @param orderdetail 订单详情
     * @return 订单详情
     */
    @Override
    public List<Orderdetail> selectOrderdetailList(Orderdetail orderdetail)
    {
        return orderdetailMapper.selectOrderdetailList(orderdetail);
    }

    /**
     * 新增订单详情
     *
     * @param orderdetail 订单详情
     * @return 结果
     */
    @Override
    public int insertOrderdetail(Orderdetail orderdetail)
    {
        orderdetail.setCreateTime(DateUtils.getTime());
        return orderdetailMapper.insertOrderdetail(orderdetail);
    }

    /**
     * 修改订单详情
     *
     * @param orderdetail 订单详情
     * @return 结果
     */
    @Override
    public int updateOrderdetail(Orderdetail orderdetail)
    {
        orderdetail.setUpdateTime(DateUtils.getTime());
        return orderdetailMapper.updateOrderdetail(orderdetail);
    }

    /**
     * 批量删除订单详情
     *
     * @param ids 需要删除的订单详情主键
     * @return 结果
     */
    @Override
    public int deleteOrderdetailByIds(Long[] ids)
    {
        return orderdetailMapper.deleteOrderdetailByIds(ids);
    }

    /**
     * 删除订单详情信息
     *
     * @param id 订单详情主键
     * @return 结果
     */
    @Override
    public int deleteOrderdetailById(Long id)
    {
        return orderdetailMapper.deleteOrderdetailById(id);
    }

    @Override
    public List<BusinessBo> getProvinceOutALPSCount() {
        return orderdetailMapper.getProvinceOutALPSCount();
    }

    @Override
    public void insertOrderdetails(Order order) {
        orderdetail.setOrderId(order.getOrderId());
        orderdetail.setCityId("0");
        orderdetail.setBuyerTel("0");
        long num=0;
        orderdetail.setNum(num);
        orderdetail.setUnit("0");
        long am=0;
        orderdetail.setAmount(am);
        long ac=0;
        orderdetail.setActualPrice(ac);
        orderdetail.setAddress("0");
        orderdetail.setRemark("0");
        orderdetail.setCreateTime(DateUtils.getTime());
        orderdetail.setUpdateTime(DateUtils.getTime());
        orderdetailMapper.insertOrderdetail(orderdetail);
    }
}
